#include "TcpServer.hpp"
#include <cstdlib>
#include <functional>
#include <iostream>
#include <memory>
#include "Command.hpp"
#include "Common.hpp"
#include "Log.hpp"

void Usage(std::string proc) {
    std::cout << "The usage is " << proc << " + port";
}

int main(int argc, char* argv[]) {
    if(argc != 2) {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }
    uint16_t port = std::stoi(argv[1]);
    EnableConsoleLogStrategy();
    Command cmd;
    std::unique_ptr<TcpServer> ts = std::make_unique<TcpServer>(port, std::bind(&Command::Execute, &cmd, std::placeholders::_1, std::placeholders::_2));
    ts->Init();
    ts->Run();
    return 0;
}